home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / v12n12.zip / PCMCVT.ZIP / PCMASM.ZIP / WRICONV.INC < prev   
Text File  |  1993-04-22  |  3KB  |  114 lines

  1. ;WRICONV.INC
  2. ;Copyright (c) 1993 Jay Munro
  3. ;First Published in PC Magazine June 29 1993
  4. ;PCMCVT Conversion module for Windows Write
  5. ;
  6. WriCVT Proc Near
  7.     Invoke Seek, SHandle, 128           ;seek to start of file
  8.     Jnc    @F
  9.     Jmp    WRIExit                      ;error, bag out
  10. @@:
  11.     Lea    SI, HeaderBuffer             ;get address of header to check
  12.     Mov    Word Ptr AX, [SI].MSWdfcMac  ;get low word of end of text
  13.     Mov    MSW4DFileEnd,AX
  14.     Mov    Word Ptr AX,[SI+2].MSWdfcMac ;and high byte
  15.     Mov    MSW4DFileEnd[2],AX
  16.     Sub    Word Ptr MSW4DFileEnd,127    ;clear off starting point
  17.     Sbb    Word Ptr MSW4DFileEnd[2],0
  18.  
  19. ReadWRIFile:
  20.     Call   WRIReadIt                    ;go read the file
  21.  
  22. RWRILoop:                               ;weed out control chars
  23.     LodSb                               ;grab a character
  24.     Sub    Word Ptr MSW4DFileEnd, 1
  25.     Sbb    Word Ptr MSW4DFileEnd[2], 0
  26.     Cmp    Word Ptr MSW4DFileEnd, 0
  27.     Jnz    @F
  28.     Cmp    Word Ptr MSW4DFileEnd[2], 0
  29.     Jnz    @F
  30.     Call   FlushIt
  31.     Jmp    WRIExit                      ;exit stage left
  32.  
  33. MSWRIFileEnd  DW 0,0
  34.  
  35. @@:
  36.     Cmp    AL,13                        ;a carriage return?
  37.     Jnz    @F     
  38.     Jmp    WriteWhatsLeft2              ;write what's in AL
  39.     
  40. @@:
  41.     Cmp    AL,10                        ;hard cr for WRI
  42.     Jnz    @F
  43.     Jmp    WriteWhatsLeft2              ;write what's in AL
  44.  
  45. @@:
  46.     Cmp    AL,'Æ'
  47.     Jnz    @F
  48.     Mov    AL,39                        ;apostrophe
  49.     Jmp    WriteWhatsLeft2              ;write what's in AL
  50.  
  51. @@:
  52.     Cmp    AL,15                        ;em dash?
  53.     Jnz    @F                           ;nope, keep going
  54.     Mov    AL,'ù'                       ;em dash symbol???
  55. @@:
  56.     Cmp    AL,'ù'
  57.     Jnz    @F
  58.     Mov    AL,'-'                       ;store dual hyphans
  59.     Call   WRIWrite
  60.     Mov    AL,'-'                       ;store dual hyphans
  61.     Jmp    WriteWhatsLeft2
  62.  
  63. @@:
  64.     Cmp    AL,2                         ;print current date;
  65.     Jnz    @F                           ;future expansion
  66.     Jmp    WRIReLoop
  67.     
  68. @@:
  69.     Cmp    AL,3                         ;print current time
  70.     Jnz    @F                           ;future expansion
  71.     Jmp    WRIReLoop
  72.     
  73. @@:
  74.     Cmp    AL,9                         ;tab
  75.     Jnz    @F
  76.     Call   DoTabs                       ;expand the tabs
  77.     Jmp    WRIReLoop
  78.     
  79. @@:
  80.     Cmp    AL,31                        ;ok, skip the rest
  81.     Jbe    WRIReLoop                       ;skip it
  82.     Cmp    AL,196                       ;two other skippers
  83.     Jz     WRIReLoop
  84.     Cmp    AL,254                       ;skip
  85.     Jae    WRIReLoop
  86.     
  87. ;write what's left
  88. WriteWhatsLeft2:
  89.     Call   WRIWrite                     ;call our local write module
  90.     Jmp    WRIReLoop
  91.  
  92. WRIReLoop:
  93.     Loop RWRILoop
  94.     Jmp  ReadWRIFile                    ;go back for more
  95.  
  96. WRIWrite:
  97.     Call   WriteIt                      ;no, then write it
  98.     Jc     WRIExit
  99.     RetN
  100.  
  101. WRIReadIt:
  102.     Call   ReadIt                       ;go read the file
  103.     Jnc    @F                           ;a fine read, continue
  104.     Mov    AL,-1                        ;a bad read, quit now
  105.     Call   WRIWrite                     ;flush buffer
  106.     Jmp    WRIExit
  107. @@:
  108.     RetN
  109.  
  110. WRIExit:
  111.     Ret
  112.  
  113. WriCVT  EndP
  114.